home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / tip / ts-outpu.tip < prev    next >
Text File  |  1993-09-15  |  5KB  |  189 lines

  1. % This macro source file is from the four volume series
  2. % "TeX in Practice" by Stephan von Bechtolsheim, published
  3. % 1993 by Springer-Verlag, New York.
  4. % Copyright 1993 Stephan von Bechtolsheim.
  5. % No warranty or liability is assumed.
  6. % This macro may be copied freely if no fees other than
  7. % media cost or shipping charges are charged and as long
  8. % as this copyright and the following source code itself
  9. % is not changed. Please see the series for further information.
  10. %
  11. % Version: 1.0
  12. % Date: May 1, 1993
  13. %
  14. %
  15. % This source code is documented in 35.9.1, p. IV-122.
  16. % Original source in file "o2.TEX", starting line 1834.
  17. \wlog{L: "ts-outpu.tip" ["o2.TEX," l. 1834, p. IV-122]}%
  18. % This file DOES belong to format "texip."
  19. \InputD{namedef.tip}
  20. \InputD{showpll.tip}
  21. \InputD{new-midi.tip}
  22. \InputD{topinfix.tip}
  23. \InputD{nathd.tip}
  24. \InputD{rangetst.tip}
  25. \newif\ifWritePageLog
  26. \WritePageLogfalse
  27. \newwrite\PageLogStream
  28. \def\WritePageLogFile{%
  29.     \immediate\openout\PageLogStream = \jobname.plog
  30.     \WritePageLogtrue
  31. }
  32. \newcount\BadnessSave
  33. \ShowPlainListsfalse
  34. \catcode`\@ = 11
  35. \newcount\@PageLayoutCode
  36. \def\SetPageLayout #1{% 
  37.     \global\@PageLayoutCode = #1
  38.     \CheckRange{\@PageLayoutCode}{0}{5}%
  39.         {\string\SetPageLayout: }
  40. }
  41. \SetPageLayout{0}%
  42. \def\@LeftRunningHead{}
  43. \def\@RightRunningHead{}
  44. \newcount\@SavedPageLayoutCode
  45. \def\NewPageRightHandSpecial{% 
  46.     \vfill
  47.     \supereject
  48.     \ifodd\count0
  49.         \wlog{\string\NewPageRightHandSpecial: no empty
  50.             page to generate (\string\count0 = \the\count0)}%
  51.     \else
  52.         \hbox{}
  53.         \@SavedPageLayoutCode = \@PageLayoutCode
  54.         \SetPageLayout{1}%
  55.         \wlog{\string\NewPageRightHandSpecial: empty page
  56.             generated,
  57.             (\string\count0 = \the\count0).}%
  58.         \vfill
  59.         \eject
  60.         \SetPageLayout{\@SavedPageLayoutCode}%
  61.     \fi
  62. }
  63. \newdimen\OddPagesHorizontalShift
  64. \newdimen\EvenPagesHorizontalShift
  65. \newdimen\CurrentPageShift
  66. \def\plainoutput{% 
  67.     \@ShowPlainLists
  68.     \edef\@LeftRunningHead{\@LeftRunningHead}%
  69.     \edef\@RightRunningHead{\@RightRunningHead}%
  70.     \ifnum\@PageLayoutCode = 0
  71.     \else
  72.         \headline = {}
  73.         \footline = {}
  74.     \fi
  75.     \ifcase\@PageLayoutCode
  76.     \or
  77.     \or
  78.         \global\@PageLayoutCode = 3
  79.     \or
  80.         \@PageLayoutCodeThree
  81.     \or
  82.         \global\@PageLayoutCode = 5
  83.     \or
  84.         \ifodd\count0
  85.             \headline = {% 
  86.                 \small\rm
  87.                 \hfil
  88.                 \botmark
  89.                 \hskip 18pt
  90.                 \PrintCounter{PageNo}%
  91.             }%
  92.         \else
  93.             \headline = {% 
  94.                 \small\rm
  95.                 \PrintCounter{PageNo}%
  96.                 \hskip 18pt
  97.                 \@LeftRunningHead
  98.                 \hfil
  99.             }%
  100.         \fi
  101.     \else
  102.         \errmessage{\string\plainoutput: \string\@PageLayoutCode
  103.             out of range.}%
  104.     \fi
  105.     \setbox 4 = \vbox{%
  106.         \pagebody
  107.     }%
  108.     \ifWritePageLog
  109.         \immediate\write\PageLogStream{%
  110.             Part name: \CurrentPartName, Page \the\count0
  111.         }%
  112.         \immediate\write\PageLogStream{%
  113.             Page \the\count0:
  114.             stretch: \the\pagestretch,
  115.             shrink: \the\pageshrink,
  116.             outputpenalty: \the\outputpenalty
  117.         }%
  118.         \immediate\write\PageLogStream{%
  119.             pagefilstretch: \the\pagefilstretch,
  120.             pagefillstretch: \the\pagefillstretch
  121.         }%
  122.         \immediate\write\PageLogStream{%
  123.             ht 255: \the\ht255,
  124.             dp 255: \the\dp255
  125.         }%
  126.         \NaturalHeight{\dimen0}{255}%
  127.         \NaturalDepth{\dimen1}{255}%
  128.         \immediate\write\PageLogStream{%
  129.             Natural height: \the\dimen0,
  130.             Natural depth:  \the\dimen1
  131.         }%
  132.         \dimen2 = \vsize
  133.         \advance\dimen2 by -\dimen0
  134.         \immediate\write\PageLogStream{%
  135.             Ideal height: \the\vsize,
  136.             Difference:  \the\dimen2
  137.         }%
  138.         \immediate\write\PageLogStream{%
  139.             badness: \the\BadnessSave,
  140.             height: \the\ht4,
  141.             depth: \the\dp4
  142.         }%
  143.         \immediate\write\PageLogStream{}%
  144.     \fi
  145.     \setbox 5 = \vbox{%
  146.         \makeheadline
  147.         \box 4
  148.         \makefootline
  149.     }%
  150.     \@MakeRobustMacros
  151.     \ifodd\count0
  152.         \CurrentPageShift = \OddPagesHorizontalShift
  153.     \else
  154.         \CurrentPageShift = \EvenPagesHorizontalShift
  155.     \fi
  156.     \wlog{Redefined \string\plainoutput (ts-outpu.tip):
  157.         Shifting: shift amount is \the\CurrentPageShift\space\space
  158.         (page is \the\pageno).}%
  159.     \setbox 6 = \vbox{%
  160.         \moveright\CurrentPageShift \box5
  161.     }%
  162.     \shipout\box6
  163.     \advancepageno
  164.     \ifnum\outputpenalty > -10000
  165.     \else
  166.         \dosupereject
  167.     \fi
  168. }
  169. \def\@PageLayoutCodeThree{%
  170.     \ifodd\count0
  171.         \headline = {% 
  172.             \small\rm
  173.             \hfil
  174.             \@RightRunningHead
  175.             \hskip 18pt
  176.             \PrintCounter{PageNo}%
  177.         }%
  178.     \else
  179.         \headline = {% 
  180.             \small\rm
  181.             \PrintCounter{PageNo}%
  182.             \hskip 18pt
  183.             \@LeftRunningHead
  184.             \hfil
  185.         }%
  186.     \fi
  187. }
  188. \catcode`\@ = 12
  189.